Component({
  data: {
    isLogin: true
  },
  lifetimes: {
    attached() {
      const isLogin = !!getApp().token
      this.setData({ isLogin })
      const pageStack = getCurrentPages()
      const currentPage = pageStack.pop()

      if (!isLogin) {
        currentPage.onLoad = () => { }
        currentPage.onShow = () => { }
        wx.redirectTo({
          url: '/pages/login/index?redirectURL=/' + currentPage.route
        })
      }

    }
  }
})